package com.yyg.boot;

import com.yyg.boot.web.UserServlet;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;

/**
 * @Author 一一哥Sun
 * @Date Created in 2020/3/29
 * @Description Description
 */
@SpringBootApplication
@ServletComponentScan(basePackages = "com.yyg.boot.web")
public class ServletApplication {

    public static void main(String[] args){
        SpringApplication.run(ServletApplication.class,args);
    }

    /**
     *ServletRegistrationBean:注册创建的Servlet类
     */
    @Bean
    public ServletRegistrationBean getServletRegistrationBean(){
        ServletRegistrationBean bean = new ServletRegistrationBean(new UserServlet());
        //url映射路径
        bean.addUrlMappings("/user");
        return bean;
    }

}
